Original Haversine Formula
$ a = sin^2left(frac{Delta text{lat}}{2}right) + cos(text{lat}_1) cdot cos(text{lat}_2) cdot sin^2left(frac{Delta text{long}}{2}right)$$c = 2 cdot text{atan2}left(sqrt{a}, sqrt{1-a}right)$$d = R cdot c$
Where:
- Δlat is the difference in latitude (in radians) between the two points.
- Δlong is the difference in longitude (in radians) between the two points.
- R is the Earth's radius (mean radius = 6,371 km or about 3,959 miles).
- lat1 and lat2 are the latitudes of the two points (in radians).
- d is the distance between the two points.
⠀⠀
Simplified Haversine Formula
$d = 2R cdot text{atan2}left(sqrt{sin^2left(frac{Delta text{lat}}{2}right) + cos(text{lat}_1) cdot cos(text{lat}_2) cdot sin^2left(frac{Delta text{long}}{2}right)}, sqrt{1 - left(sin^2left(frac{Delta text{lat}}{2}right) + cos(text{lat}_1) cdot cos(text{lat}_2) cdot sin^2left(frac{Delta text{long}}{2}right)right)}right)$
Where:
- R is the Earth's radius in the desired units
- Δlat is the difference in latitude (in radians)
- Δlong is the difference in longitude (in radians)
- lat1 and lat2 are the latitudes of the two points (in radians).
To convert from degrees to radians multiply by 180 over pi (180/π)
⠀⠀
Disclaimer: A majority of this is AI-generated